package com.zdkj.subway.check.controller.stationTiecketManager.xianWngCJXXQR;

import com.zdkj.subway.check.entity.Page;
import com.zdkj.subway.check.enums.ResultDetailMsg;
import com.zdkj.subway.check.mapper.FareDifferencesInAuditMapper;
import com.zdkj.subway.check.mapper.SwAuTvmDailyBillAssistDetailMapper;
import com.zdkj.subway.check.mapper.SwAuTvmMoneyAssistMapper;
import com.zdkj.subway.check.mapper.SwStTvmDailyBillCashPayMapper;
import com.zdkj.subway.check.result.Result;
import com.zdkj.subway.check.service.impl.subwayRat.TVMRevenueVarianceAudit.TvmChaYiDXC.TvmChaYiDXCService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 车站管理-线网层级，tvm票款差异
 */
@RequestMapping("/cz_xw")
@RestController
@Slf4j
public class Cz_xw_SwAuTvmMoneyAssistCtrl {
    /**
     * 列表
     */
    @Resource
    private SwAuTvmMoneyAssistMapper swAuTvmMoneyAssistMapper;
    @Autowired
    private TvmChaYiDXCService tvmChaYiDXCService;
    @Autowired
    private FareDifferencesInAuditMapper fareDifferencesInAuditMapper;

    /**
     * tvm票款差异协查
     * @param page
     * @param param
     * @return
     */
    @RequestMapping("/getTvmTicketCYXCNewList")
    @ApiOperation(value = "tvm票款差异协查", notes = "tvm票款差异协查")
    public Page getTvmTicketCYXCNewList(Page page,@RequestParam Map<String,String> param){
        List<Map<String,Object>> res=tvmChaYiDXCService.getTvmTicketCYXCList(param);
        page.setData(res,false);
        return page;
    }

    /**
     * TVM票款差异
     * @param page
     * @param param
     * @return
     */
    @RequestMapping("/get_cz_xw_SwAuTvmMoneyAssistList")
    @ApiOperation(value = "TVM票款差异", notes = "TVM票款差异")
    public Page get_cz_xw_SwAuTvmMoneyAssistList(Page page, @RequestParam Map<String, String> param){
        //List< Map<String,Object>> cz_xw_swAuTvmMoneyAssistList =swAuTvmMoneyAssistMapper.get_cz_xw_SwAuTvmMoneyAssistList(param);
        List< Map<String,Object>> cz_xw_swAuTvmMoneyAssistList =fareDifferencesInAuditMapper.get_cz_xw_SwAuTvmMoneyAssistList(param);
        page.setData(cz_xw_swAuTvmMoneyAssistList,true);
        return page;
    }

    @Resource
    SwAuTvmDailyBillAssistDetailMapper swAuTvmDailyBillAssistDetailMapper;//结账单据

    /**
     * 线网-TVM票款差异 结账单据查询
     * @param param
     * @return
     */
    @RequestMapping("/get_xw_pk_JieZhangDanjuData")
    @ApiOperation(value = "线网-TVM票款差异 结账单据查询", notes = "线网-TVM票款差异 结账单据查询")
    public Result get_xw_pk_JieZhangDanjuData(@RequestParam Map<String,String> param){
        Result res=new Result(ResultDetailMsg.OK);
        try{
            //线网-TVM票款差异 结账单据查询
            List< Map<String,Object>> swAuTvmDailyBillAssists = swAuTvmDailyBillAssistDetailMapper.get_xw_pk_JieZhangDanjuData(param);
            res.setData(swAuTvmDailyBillAssists);
        }catch (Exception e){
            log.error("{}",e);
            res.setResult(ResultDetailMsg.CHECK_SELECT_ERROR);
            res.setMsg("查询结账单据失败！");
        }

        return res;
    }

    @Resource
    SwStTvmDailyBillCashPayMapper swStTvmDailyBillCashPayMapper;//日结账单据（车站）（现金）
    /**
     * 线网-TVM票款差异 日结账单据查询（车站）
     * @param param
     * @return
     */
    @RequestMapping("/get_xw_pk_CarData")
    @ApiOperation(value = "线网-TVM票款差异 日结账单据查询（车站）", notes = "线网-TVM票款差异 日结账单据查询（车站）")
    public Result get_xw_pk_CarData(@RequestParam Map<String,String> param){
        Result res=new Result(ResultDetailMsg.OK);
        try{

//            QueryWrapper<SwStTvmDailyBillCashPay> queryWrapper=new QueryWrapper<>();
//            queryWrapper.eq("tvm_code",jsonObject.getString("tvmOrder"));
//            queryWrapper.le("start_time",jsonObject.getString("settleTime"));
//            queryWrapper.ge("end_time",jsonObject.getString("settleTime"));

//            List<SwStTvmDailyBillCashPay> swStTvmDailyBillCashPays = swStTvmDailyBillCashPayMapper.selectList(queryWrapper);
            //线网-TVM票款差异 日结账单据查询（车站）
            List<Map<String, Object>> swStTvmDailyBillCashPays = swStTvmDailyBillCashPayMapper.get_xw_pk_CarData(param);
            res.setData(swStTvmDailyBillCashPays);
        }catch (Exception e){
            log.error("{}",e);
            res.setResult(ResultDetailMsg.CHECK_SELECT_ERROR);
            res.setMsg("查询结账单据失败！");
        }

        return res;
    }
}
